home *** CD-ROM | disk | FTP | other *** search
- /* -----------------------------------------------------------------------------
-
- COPYIGHT
-
- ©1995 Dietmar Eilert (e-mail: DIETMAR@TOMATE.TNG.OCHE.DE). All Rights
- Reserved. Code may not be reused/reproduced without written permission of
- the author.
-
- Dietmar Eilert
- Mies-v-d-Rohe-Str.31, 52074 Aachen, Germany
- E-Mail: DIETMAR@TOMATE.TNG.OCHE.DE
- Tel: +49-(0)241-81665
- +49-(0)2525-7776
- Fax: +49-(0)241-81665
-
- Example: scan handler looking for include lines. Scan handlers are plain
- functions (LoadSeg'ed by GED): no standard C startup code, no library calls,
- one hunk.
-
- DICE C:
-
- dcc include.c -// -l0 -md -mRR -o ram:include
-
- ------------------------------------------------------------------------------
- */
-
- #include <exec/types.h>
-
- ULONG
- ScanHandlerInclude(__D0 ULONG len, __A0 char **text, __A1 ULONG *line)
- {
- const char *version = "$VER: Include 1.3 (" __COMMODORE_DATE__ ")";
-
- STRPTR textPtr = *text;
-
- // ignore leading spaces
-
- while (len && (*textPtr == ' ')) {
-
- ++textPtr;
- --len;
- }
-
- // is the next word #include ?
-
- if (len > 8) {
-
- if ((textPtr[0] == '#') && (textPtr[1] == 'i') && (textPtr[2] == 'n') && (textPtr[3] == 'c') && (textPtr[4] == 'l') && (textPtr[5] == 'u') && (textPtr[6] == 'd') && (textPtr[7] == 'e')) {
-
- textPtr += 8;
- len -= 8;
-
- // ignore spaces before argument
-
- while (len && (*textPtr == ' ')) {
-
- ++textPtr;
- --len;
- }
-
- if (len) {
-
- UWORD marker;
-
- // determine argument delimiter
-
- switch (*textPtr) {
-
- case 34:
-
- marker = 34;
-
- ++textPtr;
- --len;
-
- break;
-
- case '<':
-
- marker = '>';
-
- ++textPtr;
- --len;
-
- break;
-
- default:
-
- marker = FALSE;
- }
-
- if (len && marker) {
-
- UWORD letters = 0;
-
- // result begins here (e.g. "file name" or <file name>)
-
- *text = textPtr;
-
- // determine agument length
-
- while (--len) {
-
- ++letters;
- ++textPtr;
-
- if (*textPtr == marker)
-
- return(letters);
- }
- }
- }
- }
- }
-
- return(0);
- }
-